package mjc.compiler;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;

public class SIGNATURE implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private String nom;
	private ArrayList<DTYPE> types;
	
	public SIGNATURE(String _nom) {
		nom = _nom;
		types = new ArrayList<DTYPE>();
	}
	
	public void addType(DTYPE t) {
		types.add(t);
	}
	
	public String toString() {
		Iterator<DTYPE> i = types.iterator();
		String s = nom+"(";
		while(i.hasNext())
			s += i.next().getNom()+",";
		if (s.substring(s.length()-1, s.length()).equals(",")) {
			s = s.substring(0, s.length()-1);
		}
		s += ")";
		return s;
	}
	
	public void getTypesFromParams(PARAMETRES p) {
		Iterator<Couple<String, DTYPE>> i = p.getParams().iterator();
		while(i.hasNext())
			addType(i.next().snd);	
	}
	
}
